<template>
  <div class="app-container leftTable">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="检验项目" prop="jyxm">
        <el-input v-model="queryParams.jyxm" placeholder="请输入检验项目" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        <el-date-picker :editable="false" clearable size="small" v-model="queryParams.createTime" type="date"
          value-format="yyyy-MM-dd" placeholder="选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['Laboratory_yk_microbe_main:yk_microbe:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['Laboratory_yk_microbe_main:yk_microbe:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['Laboratory_yk_microbe_main:yk_microbe:remove']">删除</el-button>
      </el-col>
      <!--  <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['Laboratory_yk_microbe_main:yk_microbe:export']"
          >导出</el-button
        >
      </el-col> -->
      <!--      <el-col :span="1.5">-->
      <!--        <el-button-->
      <!--          type="warning"-->
      <!--          plain-->
      <!--          icon="el-icon-s-check"-->
      <!--          size="mini"-->
      <!--          :disabled="multiple"-->
      <!--          @click="handleCheck"-->
      <!--          v-hasPermi="['Laboratory_Biology:Biology:check']"-->
      <!--          >审核</el-button-->
      <!--        >-->
      <!--      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="yk_microbeList" @selection-change="handleSelectionChange" max-height="550">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" width="200px" />
      <el-table-column label="报表日期" align="center" prop="bbnf" width="200px">
        <!-- <template slot-scope="scope">
          <span>{{ parseTime(scope.row.bbnf, "{y}-{m}-{d}") }}</span>
        </template> -->
      </el-table-column>
      <el-table-column label="检验项目" align="center" prop="jyxm" :formatter="laboratory_Microbe_jyxm_Format">
        <template slot-scope="scope">
          <span>{{ scope.row.jyxm }}</span>
        </template>
      </el-table-column>
      <el-table-column label="检验依据" align="center" prop="jyyj" :formatter="laboratory_Microbe_jcyj_Format">
        <template slot-scope="scope">
          <span>{{ scope.row.jyyj }}</span>
        </template>
      </el-table-column>
      <!--  <el-table-column label="报表年份" align="center" prop="bbnf" /> -->
      <el-table-column label="报表编号" align="center" prop="bbbh" />
      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="250px">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="excelhandleView(scope.row)">导出</el-button>
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['Laboratory_yk_microbe_main:yk_microbe:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['Laboratory_yk_microbe_main:yk_microbe:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改仰口基地留样产品微生物检验记录对话框 -->
    <el-dialog v-myFullscreen fullscreen :title="title" :visible.sync="open" width="1200px" custom-class="myDialog">
      <TableHeader @nameChange="nameChange" :data="{
          mainTitle: '仰口基地留样产品微生物检验记录',
          company: '青岛崂山矿泉水有限公司',
          code: form.bbbh,
        }" />
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="报表日期" prop="bbnf">
              <el-date-picker clearable size="small" v-model="form.bbnf" type="date" value-format="yyyy-MM-dd" placeholder="选择报告日期" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="检验项目" prop="jyxm">
              <!-- <el-input v-model="form.jyxm" placeholder="请输入检验项目" :disabled="openDisabled" /> -->
              <el-checkbox-group v-model="form.jyxmsz">
                <el-checkbox v-for="dict in laboratory_Microbe_jyxm" :label="dict.dictLabel" :key="dict.dictValue"
                  :disabled="openDisabled"></el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="检验依据" prop="jyyj">
              <!-- <el-input v-model="form.jyyj" placeholder="请输入检验依据" :disabled="openDisabled" /> -->
              <!--              <el-checkbox-group v-model="form.jyyj" :disabled="openDisabled">
                <el-checkbox
                  v-for="dict in laboratory_Microbe_jcyj"
                  :label="dict.dictLabel"
                  :key="dict.dictValue"
                ></el-checkbox>
              </el-checkbox-group>-->
              <el-checkbox-group v-model="form.jyyjsz">
                <el-checkbox v-for="dict in laboratory_Microbe_jcyj" :label="dict.dictLabel" :key="dict.dictValue"
                  :disabled="openDisabled"></el-checkbox>
              </el-checkbox-group>

              <!-- <el-radio-group v-model="form.jyyj">
                <el-radio
                  v-for="dict in laboratory_Microbe_jcyj"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                  :disabled="openDisabled"
                ></el-radio>
              </el-radio-group>-->
            </el-form-item>
          </el-col>

          <!-- 项目名称 -->
          <!-- <el-row> -->
          <el-col :span="2">
            <el-form-item label="项目名称" label-width="100%" />
          </el-col>
          <el-col :span="4">
            <el-form-item label="菌落总数（CFU/ml)" label-width="100%" />
          </el-col>
          <el-col :span="3">
            <el-form-item label="霉菌(CFU/ml)" label-width="100%" />
          </el-col>
          <el-col :span="3">
            <el-form-item label="酵母菌(CFU/ml)" label-width="100%" />
          </el-col>
          <el-col :span="4">
            <el-form-item label="大肠菌群(CFU/ml)" label-width="100%" />
          </el-col>
          <el-col :span="4">
            <el-form-item label="大肠菌群(MPN/100ml)" label-width="100%" />
          </el-col>
          <el-col :span="4">
            <el-form-item label="铜绿(MPN/250ml)" label-width="100%" />
          </el-col>
          <!-- </el-row> -->
          <!-- 培养条件 -->
          <!-- <el-row> -->
          <el-col :span="2">
            <el-form-item label="培养条件" label-width="100%" />
          </el-col>
          <el-col :span="4">
            <el-form-item label="36±1℃：48h±2h" label-width="100%" />
          </el-col>
          <el-col :span="6">
            <el-form-item label="28±1℃；5d" label-width="100%" class="center" />
          </el-col>
          <el-col :span="4">
            <el-form-item label="平板计数:36±1℃;18～24 h" label-width="100%" />
          </el-col>
          <el-col :span="4">
            <el-form-item label="36±1℃;24 h" label-width="100%" />
          </el-col>
          <el-col :span="4">
            <el-form-item label="36±1℃；24～48 h" label-width="100%" />
          </el-col>
          <!-- </el-row> -->

          <!-- <el-col :span="12">
                <el-form-item label="报表年份" prop="bbnf">
                  <el-input v-model="form.bbnf" placeholder="请输入报表年份" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="报表编号" prop="bbbh">
                  <el-input v-model="form.bbbh" placeholder="请输入报表编号" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" placeholder="请输入备注" :disabled="openDisabled" />
                </el-form-item>
            </el-col> -->
        </el-row>

        <br />
        <el-divider content-position="center">仰口基地留样产品微生物检验记录子1信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddQualityLabYkMicrobeSub1"
              :disabled="openDisabled">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteQualityLabYkMicrobeSub1"
              :disabled="openDisabled">删除</el-button>
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <!-- @selection-change="handleQualityLabYkMicrobeSub1SelectionChange" -->
        <el-table :data="qualityLabYkMicrobeSub1List" :row-class-name="rowQualityLabYkMicrobeSub1Index"
          :span-method="objectSpanMethod" border ref="qualityLabYkMicrobeSub1">
          <el-table-column type="selection" width="50" align="center" />
          <!-- <el-table-column label="序号" align="center" prop="index" width="50"/> -->
          <el-table-column label="名称" prop="mc" width="320">
            <template slot-scope="scope">
              <div>
                <el-input placeholder="空白对照组" :disabled="true" />
              </div>
              <div>
                <!-- <el-input
                  v-model="scope.row.mc"
                  placeholder="请输入名称"
                  :disabled="openDisabled"
                /> -->
                <Dialog @dialogChange="
                    qualityLabYkMicrobeSub1List[scope.$index].mc = $event.label
                  " :echoValue="scope.row.mc" parameter="rows" value="id" label="name" :multiple="false"
                  search="name/code" url="/basic/productInfo/listSelect" :column="['产成品编号/code', '产成品名称/name']"
                  placeholder="请选择内容" :axiosData="{ typeCode: 'YYTRKQS' }" :openDisabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="样品编号" prop="ypbh" width="200">
            <template slot-scope="scope">
              <div>
                <el-input v-model="scope.row.ypbhdz" placeholder="请输入样品编号" :disabled="openDisabled" />
              </div>
              <div>
                <el-input v-model="scope.row.ypbh" placeholder="请输入样品编号" :disabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="菌落总数平板1" prop="jlzs1" width="200">
            <template slot-scope="scope">
              <div>
                <el-input v-model="scope.row.jlzsdz" placeholder="菌落总数对照" :disabled="openDisabled" />
              </div>
              <div>
                <el-input v-model="scope.row.jlzs1" placeholder="请输入菌落总数平板1" :disabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="菌落总数平板2" prop="jlzs2" width="200">
            <template slot-scope="scope">
              <div>
                <el-input :disabled="true" />
              </div>
              <div>
                <el-input v-model="scope.row.jlzs2" placeholder="请输入菌落总数平板2" :disabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="霉菌酵母菌平板1" prop="mjpb1" width="200">
            <template slot-scope="scope">
              <div>
                <el-input v-model="scope.row.mjjmjdz" placeholder="霉菌酵母菌对照" :disabled="openDisabled" />
              </div>
              <div>
                <el-input v-model="scope.row.mjpb1" placeholder="请输入霉菌酵母菌平板1" :disabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="霉菌酵母菌平板2" prop="jmjpb2" width="200">
            <template slot-scope="scope">
              <div>
                <el-input :disabled="true" />
              </div>
              <div>
                <el-input v-model="scope.row.jmjpb2" placeholder="请输入霉菌酵母菌平板2" :disabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="大肠菌群平板1" prop="dcjqpad1" width="200">
            <template slot-scope="scope">
              <div>
                <el-input v-model="scope.row.dcjqdz" placeholder="大肠菌群对照" :disabled="openDisabled" />
              </div>
              <div>
                <el-input v-model="scope.row.dcjqpad1" placeholder="请输入大肠菌群" :disabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="大肠菌群平板2" prop="dcjqpad2" width="200">
            <template slot-scope="scope">
              <div>
                <el-input :disabled="true" />
              </div>
              <div>
                <el-input v-model="scope.row.dcjqpad2" placeholder="请输入大肠菌群" :disabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="10ml水样" prop="dcjpsy" width="200">
            <template slot-scope="scope">
              <div>
                <el-input v-model="scope.row.dcjpsydz" placeholder="10ml水样对照" :disabled="openDisabled" />
              </div>
              <div>
                <el-input v-model="scope.row.dcjpsy" placeholder="请输入大肠菌群" :disabled="openDisabled" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="蓝色/绿色" prop="tlbluegreen" width="200">
            <template slot-scope="scope">
              <el-select v-model="scope.row.tlbluegreen" placeholder="请选择铜绿" style="width: 100%"
                :disabled="openDisabled">
                <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel"
                  :value="dict.dictValue"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="产荧光（非蓝/绿）" prop="tlnogluegreen" width="200">
            <template slot-scope="scope">
              <el-select v-model="scope.row.tlnogluegreen" placeholder="请选择铜绿" style="width: 100%"
                :disabled="openDisabled">
                <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel"
                  :value="dict.dictValue"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="红褐色" prop="tlred" width="200">
            <template slot-scope="scope">
              <el-select v-model="scope.row.tlred" placeholder="请选择铜绿" style="width: 100%" :disabled="openDisabled">
                <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel"
                  :value="dict.dictValue"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="其他形态" prop="tlother" width="200">
            <template slot-scope="scope">
              <el-select v-model="scope.row.tlother" placeholder="请选择铜绿" style="width: 100%" :disabled="openDisabled">
                <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel"
                  :value="dict.dictValue"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="检验结论" prop="jyjl" width="200">
            <template slot-scope="scope">
              <el-input type="textarea" v-model="scope.row.jyjl" placeholder="请输入检验结论" :disabled="openDisabled" />
            </template>
          </el-table-column>
          <el-table-column label="检验日期" prop="jyrq" width="200">
            <template slot-scope="scope">
              <el-date-picker :editable="false" clearable v-model="scope.row.jyrq" type="date" value-format="yyyy-MM-dd"
                placeholder="选择检验日期" :disabled="openDisabled">
              </el-date-picker>
            </template>
          </el-table-column>
          <el-table-column label="检验人" prop="jyr" width="200">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.jyr"
                placeholder="请输入检验人"
                :disabled="openDisabled"
              /> -->
              <el-select v-model="scope.row.jyr" filterable allow-create placeholder="请选择检验人" style="width: 100%"
                :disabled="openDisabled">
                <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"
                  :disabled="openDisabled"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="复核人" prop="fhr" width="200">
            <template slot-scope="scope">
              <UserDialog @dialogChange="scope.row.fhr = $event.label" :echoValue="scope.row.fhr" :multiple="false"
                :openDisabled="openDisabled" />
              <!--              <el-input-->
              <!--                v-model="scope.row.fhr"-->

              <!--                :disabled="true"-->
              <!--              />-->
            </template>
          </el-table-column>
          <!-- <el-table-column label="报表编号" prop="bbbh">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.bbbh"
                placeholder="请输入报表编号"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.remark"
                placeholder="请输入备注"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column> -->
        </el-table>

        <!-- <el-divider content-position="center">仰口基地留样产品微生物检验记录子2信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddQualityLabYkMicrobeSub2" :disabled="openDisabled">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteQualityLabYkMicrobeSub2" :disabled="openDisabled">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="qualityLabYkMicrobeSub2List" :row-class-name="rowQualityLabYkMicrobeSub2Index" @selection-change="handleQualityLabYkMicrobeSub2SelectionChange" ref="qualityLabYkMicrobeSub2">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="样品名称" prop="ypmc">
            <template slot-scope="scope">
                <el-input v-model="scope.row.ypmc" placeholder="请输入样品名称" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="样品编号" prop="ypbh">
            <template slot-scope="scope">
                <el-input v-model="scope.row.ypbh" placeholder="请输入样品编号" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="菌落总数" prop="jlzs">
            <template slot-scope="scope">
                <el-input v-model="scope.row.jlzs" placeholder="请输入菌落总数" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="霉菌-酵母菌" prop="mjjmj">
            <template slot-scope="scope">
                <el-input v-model="scope.row.mjjmj" placeholder="请输入霉菌-酵母菌" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="大肠菌群" prop="dcjqother">
            <template slot-scope="scope">
                <el-input v-model="scope.row.dcjqother" placeholder="请输入大肠菌群" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="大肠菌群" prop="dcjqkq">
            <template slot-scope="scope">
                <el-input v-model="scope.row.dcjqkq" placeholder="请输入大肠菌群" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="铜绿" prop="tlkq">
            <template slot-scope="scope">
                <el-input v-model="scope.row.tlkq" placeholder="请输入铜绿" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" placeholder="请输入备注" :disabled="openDisabled"/>
            </template>
          </el-table-column>
        </el-table> -->
      </el-form>
      <div slot="footer" class="dialog-footer" v-if="!openDisabled">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {
    listYk_microbe,
    getYk_microbe,
    delYk_microbe,
    addYk_microbe,
    updateYk_microbe,
    checkYk_microbe,
  } from "@/api/quality/laboratory/yk_microbe";
  import { getInfo } from "@/api/login";
  import { listUser } from "@/api/system/user";

  export default {
    name: "Yk_microbe",
    data() {
      return {
        //弹窗是否禁止编辑
        openDisabled: true,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 子表选中数据
        checkedQualityLabYkMicrobeSub2: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 仰口基地留样产品微生物检验记录表格数据
        yk_microbeList: [],
        // 仰口基地留样产品微生物检验记录子1表格数据
        qualityLabYkMicrobeSub1List: [],
        // 仰口基地留样产品微生物检验记录子2表格数据
        qualityLabYkMicrobeSub2List: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 50,
          jyxm: null,
          createTime: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        laboratory_Microbe_jyxm: "",
        laboratory_Microbe_jcyj: "",
        /* 当前用户名 */
        nickName: "",
        userList: [],
      };
    },
    created() {
      this.getList();
      this.queryUserList();
      this.getDicts("laboratory_Microbe_jyxm").then((response) => {
        this.laboratory_Microbe_jyxm = response.data;
      });
      this.getDicts("laboratory_Microbe_jcyj").then((response) => {
        this.laboratory_Microbe_jcyj = response.data;
        console.log(this.laboratory_Microbe_jcyj);
      });
      this.getDicts("laboratory_Microbe_tl").then((response) => {
        this.laboratory_Microbe_tl = response.data;
      });
    },
    methods: {
      /** 查询仰口基地留样产品微生物检验记录列表 */
      getList() {
        this.loading = true;
        listYk_microbe(this.queryParams).then((response) => {
          this.yk_microbeList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      laboratory_Microbe_jyxm_Format(row, column) {
        return this.selectDictLabel(this.laboratory_Microbe_jyxm, row.jyxm);
      },
      laboratory_Microbe_jcyj_Format(row, column) {
        return this.selectDictLabel(this.laboratory_Microbe_jcyj, row.jyyj);
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          jyxm: null,
          jyxmsz: [],
          jyyj: null,
          jyyjsz: [],
          bbnf: null,
          bbbh: "LK-QF-LS1-10-012-11-01",
          remark: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          delFlag: null,
        };
        this.qualityLabYkMicrobeSub1List = [];
        this.qualityLabYkMicrobeSub2List = [];
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map((item) => item.id);
        this.single = selection.length !== 1;
        this.multiple = !selection.length;
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.openDisabled = false;
        this.open = true;
        this.title = "添加仰口基地留样产品微生物检验记录";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        this.openDisabled = false;
        const id = row.id || this.ids;
        getYk_microbe(id).then((response) => {
          this.form = response.data;
          this.qualityLabYkMicrobeSub1List =
            response.data.qualityLabYkMicrobeSub1List;
          this.qualityLabYkMicrobeSub2List =
            response.data.qualityLabYkMicrobeSub2List;
          this.open = true;
          this.title = "修改仰口基地留样产品微生物检验记录";
        });
      },
      /** 查看按钮 */
      handleView(row) {
        this.reset();
        this.openDisabled = true;
        const id = row.id || this.ids;
        getYk_microbe(id).then((response) => {
          this.form = response.data;
          this.qualityLabYkMicrobeSub1List =
            response.data.qualityLabYkMicrobeSub1List;
          this.qualityLabYkMicrobeSub2List =
            response.data.qualityLabYkMicrobeSub2List;
          this.open = true;
          this.title = "查看仰口基地留样产品微生物检验记录";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            this.form.qualityLabYkMicrobeSub1List =
              this.qualityLabYkMicrobeSub1List;
            this.form.qualityLabYkMicrobeSub2List =
              this.qualityLabYkMicrobeSub2List;
            if (this.form.id != null) {
              updateYk_microbe(this.form).then((response) => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addYk_microbe(this.form).then((response) => {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm(
          '是否确认删除仰口基地留样产品微生物检验记录编号为"' +
          ids +
          '"的数据项?',
          "警告",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        )
          .then(function () {
            return delYk_microbe(ids);
          })
          .then(() => {
            this.getList();
            this.msgSuccess("删除成功");
          })
          .catch(() => { });
      },
      /** 仰口基地留样产品微生物检验记录子2序号 */
      rowQualityLabYkMicrobeSub2Index({ row, rowIndex }) {
        row.index = rowIndex + 1;
      },
      /** 仰口基地留样产品微生物检验记录子2添加按钮操作 */
      handleAddQualityLabYkMicrobeSub2() {
        let obj = {};
        obj.ypmc = "";
        obj.ypbh = "";
        obj.jlzs = "";
        obj.mjjmj = "";
        obj.dcjqother = "";
        obj.dcjqkq = "";
        obj.tlkq = "";
        obj.remark = "";
        this.qualityLabYkMicrobeSub2List.push(obj);
      },
      /** 仰口基地留样产品微生物检验记录子2删除按钮操作 */
      handleDeleteQualityLabYkMicrobeSub2() {
        if (this.checkedQualityLabYkMicrobeSub2.length == 0) {
          this.$alert(
            "请先选择要删除的仰口基地留样产品微生物检验记录子2数据",
            "提示",
            { confirmButtonText: "确定" }
          );
        } else {
          this.qualityLabYkMicrobeSub2List.splice(
            this.checkedQualityLabYkMicrobeSub2[0].index - 1,
            1
          );
        }
      },
      /** 单选框选中数据 */
      handleQualityLabYkMicrobeSub2SelectionChange(selection) {
        if (selection.length > 1) {
          this.$refs.qualityLabYkMicrobeSub2.clearSelection();
          this.$refs.qualityLabYkMicrobeSub2.toggleRowSelection(selection.pop());
        } else {
          this.checkedQualityLabYkMicrobeSub2 = selection;
        }
      },
      /** 仰口基地留样产品微生物检验记录子1序号 */
      rowQualityLabYkMicrobeSub1Index({ row, rowIndex }) {
        row.index = rowIndex + 1;
      },
      /** 仰口基地留样产品微生物检验记录子1添加按钮操作 */
      handleAddQualityLabYkMicrobeSub1() {
        let obj = {};
        obj.mc = "";
        obj.ypbh = "";
        obj.jlzs1 = "";
        obj.jlzs2 = "";
        obj.mjpb1 = "";
        obj.jmjpb2 = "";
        obj.dcjqpad1 = "空";
        obj.dcjqpad2 = "空";
        obj.dcjpsy = "空";
        obj.tlbluegreen = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlnogluegreen = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlred = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlother = this.laboratory_Microbe_tl[0].dictValue;
        obj.bbbh = "";
        obj.remark = "";
        obj.jyjl = "";
        obj.jyrq = "";
        obj.jyr = this.nickName;
        obj.fhr = "";
        //对照组
        obj.ypbhdz = "0";
        obj.jlzsdz = "";
        obj.mjjmjdz = "";
        obj.dcjqdz = "空";
        obj.dcjpsydz = "空";
        this.qualityLabYkMicrobeSub1List.push(obj);
      },
      /** 仰口基地留样产品微生物检验记录子1删除按钮操作 */
      handleDeleteQualityLabYkMicrobeSub1() {
        if (this.checkedQualityLabYkMicrobeSub1.length == 0) {
          this.$alert(
            "请先选择要删除的仰口基地留样产品微生物检验记录子1数据",
            "提示",
            { confirmButtonText: "确定" }
          );
        } else {
          this.qualityLabYkMicrobeSub1List.splice(
            this.checkedQualityLabYkMicrobeSub1[0].index - 1,
            1
          );
        }
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download(
          "Laboratory_yk_microbe_main/yk_microbe/export",
          {
            ...this.queryParams,
          },
          `Laboratory_yk_microbe_main_yk_microbe.xlsx`
        );
      },
      excelhandleView(row) {
        this.download(
          "Laboratory/yk_microbe/exportexcel?id=" + row.id,
          {
            ...this.queryParams,
          },
          "仰口基地留样产品微生物检验记录" + this.parseTime(new Date()) + ".xlsx"
        );
      },
      //接收编号
      nameChange(e) {
        this.form.bbbh = e;
      },
      /** 合并行  */
      objectSpanMethod({ row, column, rowIndex, columnIndex }) {
        // if (columnIndex === 0 || columnIndex === 1) {
        //   if (rowIndex % 2 === 0) {
        //     return {
        //       rowspan: 2,
        //       colspan: 1,
        //     };
        //   } else {
        //     return {
        //       rowspan: 0,
        //       colspan: 0,
        //     };
        //   }
        // }
        /* if (columnIndex === 10 || columnIndex === 11 || columnIndex === 12 || columnIndex === 13) {
          if (rowIndex % 2 === 0) {
            return {
              rowspan: 1,
              colspan: 4,
            };
          } else {
            return {
              rowspan: 1,
              colspan: 1,
            };
          }
        } */
        // if (columnIndex === 14 || columnIndex === 15 || columnIndex === 16) {
        //   if (rowIndex % 2 === 0) {
        //     return {
        //       rowspan: 2,
        //       colspan: 1,
        //     };
        //   } else {
        //     return {
        //       rowspan: 1,
        //       colspan: 1,
        //     };
        //   }
        // }
      },
      /** 审核按钮操作 */
      handleCheck(row) {
        /* 审核 */
        this.ids.forEach((id) => {
          getYk_microbe(id).then((response) => {
            // console.log(response)
            let s = response.data.qualityLabYkMicrobeSub1List[0].fhr;
            if (s != null && s != "") {
              this.msgError(
                '编号为"' + id + '"的数据项已审核完成，无需重复审核！'
              );
            } else {
              let obj = {};
              obj.id = id;
              obj.qualityLabYkMicrobeSub1List = this.qualityLabYkMicrobeSub1List;
              obj.qualityLabYkMicrobeSub1List[0].fhr = this.nickName;
              obj.qualityLabYkMicrobeSub2List = this.qualityLabYkMicrobeSub2List;
              /* 修改 */
              checkYk_microbe(obj).then((response) => {
                this.msgSuccess('编号为"' + id + '"的数据项审核成功！');
                this.getList();
              });
            }
          });
        });
      },
      /* 查询用户列表 */
      queryUserList() {
        listUser().then((response) => {
          this.userList = response.rows;
        });
        getInfo().then((response) => {
          this.nickName = response.user.nickName;
        });
      },
    },
  };
</script>
<style>
  .leftTable .el-form-item__label {
    text-align: left !important;
  }

  .leftTable .center .el-form-item__label {
    text-align: center !important;
  }
</style>